package com.lenovo.website.taobao;

import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.util.EntityUtils;

import com.lenovo.util.HttpUtil;
import com.lenovo.website.tmall.JsonDataTag;
import com.lenovo.website.tmall.TmallItem;
import com.lenovo.website.tmall.TmallOnlyTagItem;

public class AllTaoBaoAndTiaoMao {
	
	static public void main(String[] args){
		try {
			for(int i=0;i<600;i+=60){
				HttpEntity urlentity=null ;
				if(i==0){
				 urlentity=	HttpUtil.httpGet("http://list.tmall.com/search_product.htm?q=%D3%C5%C5%CC&type=p&spm=a220m.1000858.a2227oh.d100&from=tmallsearch_1_searchbutton", true);
				}else{
					 urlentity=	HttpUtil.httpGet("http://list.tmall.com/search_product.htm?q=%D3%C5%C5%CC&type=p&spm=a220m.1000858.a2227oh.d100&from=tmallsearch_1_searchbutton&s="+i, true);
				}
				String content = EntityUtils.toString(urlentity);
			
			    List<String>  listhoemurl= HtmlTbUtil.search(content) ;
				for(String str:listhoemurl){
					System.out.println(str);
					String itemId = str.substring(str.indexOf("id") + 3,
							str.indexOf("&areaId"));
					List<JsonDataTag> tagList=TmallOnlyTagItem.tag(str, true);
					for(JsonDataTag tagurl:tagList){
						TmallOnlyTagItem.tagAndtitle(str, tagurl.getId(),tagurl.getTag(),itemId, true,null);
					}
				}
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

}
